package com.xls.commonlibrary.util;

import android.app.Activity;
import android.content.Context;

import com.bytedance.sdk.openadsdk.mediation.ad.MApiIMediationViewBinderReversal;
import com.hjq.toast.Toaster;
import com.orhanobut.logger.Logger;
import com.xls.commonlibrary.http.Api;
import com.xls.commonlibrary.http.RetrofitHelper;
import com.xls.commonlibrary.http.RxLifecycle;
import com.xls.commonlibrary.http.Transformer;
import com.xls.commonlibrary.http.exception.ThrowableUtil;
import com.xls.commonlibrary.util.eventbus.MessageEvent;

import org.greenrobot.eventbus.EventBus;

import java.util.HashMap;
import java.util.Map;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.util.TimeUtils;

import static com.xls.commonlibrary.util.eventbus.ConstEventBus.EVENT_LOGIN_DISSMISS_DIALOG;

/**
 * @author lhx
 * @description:
 * @date : 2024/4/12 12:05
 */
public class AdvertisingBackdropsPointsUtil {
    private static volatile AdvertisingBackdropsPointsUtil singleton = null;

    private AdvertisingBackdropsPointsUtil() {
    }

    public static AdvertisingBackdropsPointsUtil getInstance() {
        if (singleton == null) {
            synchronized (AdvertisingBackdropsPointsUtil.class) {
                if (singleton == null) {
                    singleton = new AdvertisingBackdropsPointsUtil();
                }
            }
        }
        return singleton;
    }
    public interface Type{
        int jili=0;
    }

    public interface JILIOnClickListener{
        String RewardVideoAd_onError="RewardVideoAd_onError";
        String RewardVideoAd_onRewardVideoAdLoad="RewardVideoAd_onRewardVideoAdLoad";
        String RewardVideoAd_onRewardVideoCached = "RewardVideoAd_onRewardVideoCached";
        String RewardAdInteraction_onAdShow = "RewardAdInteraction_onAdShow";
        String RewardAdInteraction_onAdVideoBarClick = "RewardAdInteraction_onAdVideoBarClick";
        String RewardAdInteraction_onAdClose = "RewardAdInteraction_onAdClose";
        String RewardAdInteraction_onVideoComplete = "RewardAdInteraction_onVideoComplete";
        String RewardAdInteraction_onVideoError = "RewardAdInteraction_onVideoError";
        String RewardAdInteraction_onRewardVerify = "RewardAdInteraction_onRewardVerify";//gromore废弃
        String RewardAdInteraction_onRewardArrived = "RewardAdInteraction_onRewardArrived";
        String RewardAdInteraction_onSkippedVideo = "RewardAdInteraction_onSkippedVideo";
    }

    public interface JILIOnClickListenerSTR{
        String RewardVideoAd_onError="广告拉取_失败";
        String RewardVideoAd_onRewardVideoAdLoad="广告拉取_拉取到广告";
        String RewardVideoAd_onRewardVideoCached = "广告拉取_缓存完成";
        String RewardAdInteraction_onAdShow = "广告展示_播放";
        String RewardAdInteraction_onAdVideoBarClick = "广告展示_按钮点击";
        String RewardAdInteraction_onAdClose = "广告展示_关闭";
        String RewardAdInteraction_onVideoComplete = "广告展示_播放完成";
        String RewardAdInteraction_onVideoError = "广告展示_失败报错";
        String RewardAdInteraction_onRewardVerify = "广告展示_播放成功";//gromore废弃
        String RewardAdInteraction_onRewardArrived = "广告展示_播放满足奖励条件";
        String RewardAdInteraction_onSkippedVideo = "广告展示_跳过";
    }
    public void JiLiVideo(AppCompatActivity context,String codeid, String trans_id, String click_type, String remark){
        Map<String,String> params=new HashMap<>();
        params.put("trans_id",trans_id);
        params.put("video_type",Type.jili+"");
        params.put("click_type",click_type);
        params.put("company",context.getPackageName());
        long currentTimeMillis = System.currentTimeMillis();
        params.put("app_time",currentTimeMillis+"" );
        params.put("remark",codeid+"_"+remark);
        // 请求接口,返回Result
        RetrofitHelper.getInstance().create(Api.class)
                .saveAppUserVideo(params)
                .compose(Transformer.transform())
                .compose(RxLifecycle.bindRxLifecycle(context))
                .subscribe(
                        result -> {
                            Logger.e("广告回掉"+result);
                            if (result.getCode() == 1) {



                            } else {


                            }
                        },
                        throwable -> {

                        }
                );

    }
}
